﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.Models;
using PBOffice.BLL;


public partial class Admin_Login : System.Web.UI.Page
{
    List<Staff> list = new StaffManager().GetAllStaff("", "", "");
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string user = this.txtUserName.Text.Trim();
        string pwd = this.txtPwd.Text.Trim();
        bool result = false;
        foreach (Staff item in list)
        {
            if (item.StfCode==user && item.Password==pwd)
            {
                result = true;
                Session["username"] = item;
            }
        }
        if (result == true)
        {
            Response.Redirect("Index.aspx");
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('用户编号或者密码错误！')</script>");
        }

    }
}